/*
 * Copyright 2005-2007 Pulse Technologies. Tutti i diritti riservati.
 */

package org.obsidianrad.server.services.obj2db.commodities;

import java.util.Comparator;

/**
 * 
 * @author eliosh
 * @version $Rev: 77 $
 * @lastautorcommit $Author: eliosh $
 * @lastdatecommit $Date: 2010-01-26 09:20:33 +0100(mar, 26 gen 2010) $
 */
/**
 * Defines GXT public constants and enumerations.
 */
public class Style {

	/**
	 * Horizontal alignment enumeration.
	 */
	public enum HorizontalAlignment {
		LEFT, CENTER, RIGHT
	}

	/**
	 * Vertical alignment enumerations.
	 */
	public enum VerticalAlignment {
		TOP, MIDDLE, BOTTOM;
	}

	/**
	 * Scroll enumeration.
	 */
	public enum Scroll {
		AUTO("auto"), AUTOX("auto"), AUTOY("auto"), ALWAYS("scroll"), NONE("hidden");
		private final String value;

		private Scroll(String value) {
			this.value = value;
		}

		public String value() {
			return value;
		}
	}

	/**
	 * Sort direction enum.
	 */
	public enum SortDir {

		NONE {
			@SuppressWarnings("unchecked")
			@Override
			public Comparator comparator(Comparator c) {
				return c;
			}
		},

		ASC {
			@Override
			public <X> Comparator<X> comparator(final Comparator<X> c) {
				return new Comparator<X>() {
					public int compare(X o1, X o2) {
						return c.compare(o1, o2);
					}
				};
			}
		},

		DESC {
			@Override
			public <X> Comparator<X> comparator(final Comparator<X> c) {
				return new Comparator<X>() {
					public int compare(X o1, X o2) {
						return c.compare(o2, o1);
					}
				};
			}
		};

		public static SortDir toggle(SortDir sortDir) {
			return (sortDir == ASC) ? DESC : ASC;
		}

		/**
		 * An example of how to use this :
		 * 
		 * List<Something> list = ...
		 * 
		 * Collections.sort(list, SortDir.ASC.comparator(new Comparator() {
		 * public int compare(Object o1, Object o2) { return ... } });
		 * 
		 * 
		 * @return a Comparator that wraps the specific comparator that orders
		 *         the results acording to the sort direction
		 */
		public abstract <X> Comparator<X> comparator(Comparator<X> c);
	}

	/**
	 * Layout out regions.
	 */
	public enum LayoutRegion {
		NORTH, EAST, SOUTH, WEST, CENTER;
	}

	public enum Direction {
		UP, DOWN, LEFT, RIGHT;
	}

	/**
	 * Scroll direction enum.
	 */
	public enum ScrollDir {
		VERTICAL, HORIZONTAL;
	}

	/**
	 * Selection mode enum.
	 */
	public enum SelectionMode {
		SINGLE, SIMPLE, MULTI;
	}

	/**
	 * Orientation enum.
	 */
	public enum Orientation {
		VERTICAL, HORIZONTAL;
	}

	/**
	 * A constant known to be zero (0).
	 */
	public static final int NONE = 0;

	/**
	 * Indicates that a default value should be used (value is -1).
	 */
	public static final int DEFAULT = -1;

	/**
	 * Constant for marking a string as undefined rather than null.
	 */
	public static final String UNDEFINED = "undefined";

}
